﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QLTV_V2.BussinessLogic;
using QLTV_V2.BussinessObject;
using QLTV_V2.DataAccess;
namespace QLTV_V2
{
    public partial class FrmXemCTSach : DevComponents.DotNetBar.Office2007RibbonForm
    {
        public FrmXemCTSach()
        {
            InitializeComponent();
        }
        public string madausach;
        Utilities uti = new Utilities();
        DauSach ds = new DauSach();
        SachBUS sachBUS = new SachBUS();
        private void FrmXemCTSach_Load(object sender, EventArgs e)
        {
            //Load combobox loại sách
            comb_LoaiSach.DataSource = uti.getDataSource("LoaiSach", "TenLoaiSach");
            comb_LoaiSach.DisplayMember = "TenLoaiSach";
            comb_LoaiSach.ValueMember = "MaLoaiSach";
            //Load combobox Tac gia
            comb_TacGia.DataSource = uti.getDataSource("TacGia", "TenTacGia");
            comb_TacGia.DisplayMember = "TenTacGia";
            comb_TacGia.ValueMember = "MaTacGia";
            //Load combox Ngon ngu'
            comb_NgonNgu.DataSource = uti.getDataSource("NgonNgu", "TenNgonNgu");
            comb_NgonNgu.DisplayMember = "TenNgonNgu";
            comb_NgonNgu.ValueMember = "MaNgonNgu";
            //Load combobox nha xuat ban
            comb_NhaXB.DataSource = uti.getDataSource("NhaXuatBan", "TenNXB");
            comb_NhaXB.DisplayMember = "TenNXB";
            comb_NhaXB.ValueMember = "MaNXB";
            //Load du lieu ra các điều khiển
            ds = sachBUS.getDauSach_object("tendausach", "maloaisach", madausach, 2);
            txt_MaDauSach.Text = ds.MaDauSach;
            txt_TenDauSach.Text = ds.TenDauSach;
            comb_LoaiSach.SelectedValue = ds.MaLoaiSach;
            txt_KHPhanLoai.Text = ds.KHPhanLoai;
            txt_SoISBN.Text = ds.SoISBN;
            comb_TacGia.SelectedValue = ds.MaTacGia;
            comb_NhaXB.SelectedValue = ds.MaNXB;
            comb_NgonNgu.SelectedValue = ds.MaNgonNgu;
            txt_NamXB.Text = ds.NamXB.ToString();
            txt_GiaBia.Text = ds.GiaBia.ToString();
            txt_TomTatND.Text = ds.TomtatND;
            //Load dữ liệu ra dgv_BanSach
            dgv_BanSach.DataSource = uti.getDataSource_DK("BanSach", "MaDauSach", madausach, "MaBanSach");

        }
        //Thêm số thứ tự dòng vào RowHeader của DataGridV
        private void dgv_BanSach_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
            uti.dgv_GetSTT_RowHeader(sender, e, dgv_BanSach);
        }

        private void btn_Thoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
